<template>

	<scroll-view class="layout" style="position: relative;">
		<view class="mask" v-if="showMask" @click="closeAllModals">
		</view>
		<view class="popup-menu" v-if="showMenu">
			<view class="menu-item">指标显示</view>
			<view @click="goOneRm" class="menu-item">1RM测试</view>
			<view class="menu-item">播报设置</view>
			<view @click="gotoDefine" class="menu-item">指标释义</view>
			<view class="menu-item end" style="color: #e74c3c;">结束训练</view>
		</view>
		<!-- 负荷弹窗掩膜 -->
		<view class="mask" v-if="showMask" @click="closeAllModals"></view>
		<!-- 负荷弹窗 -->
		<view class="load-popup" v-if="showLoadPopup">
			<view class="load-popup-left">
				<view class="load-popup-item left_module"
					style="padding-left: 20rpx;  white-space: nowrap;  background: rgba(240,240,240,1); ">

					{{ aim_name }}<text class="desc" style="font-size: 10rpx;">目的</text>
				</view>
				<view class="load-popup-item editable left_module" :class="{active: loadInputTarget==='1RM'}"
					@click="setLoadInput('1RM')" style="">
					<view class="" style="display: flex; justify-content: center; ">
						{{ load1RM }}
					</view>


					<text class="desc" style="font-size: 10rpx;">1RM/kg</text>
				</view>
				<view class="load-popup-item editable left_module" :class="{active: loadInputTarget==='weight'}"
					@click="setLoadInput('weight')" style="">
					<view class="" style=" display: flex; justify-content: center; ">
						{{ loadWeight }}
					</view>

					<text class="desc" style="display: flex; font-size: 10rpx; justify-content: center; ">负荷/kg</text>
				</view>
				<view class="load-popup-item left_module" style="background: rgba(124,124,126,0.2);">
					<view class="" style="display: flex; justify-content: center; ">
						{{ loadRIR }}
					</view>

					<text class="desc" style="display: flex; font-size: 10rpx; justify-content: center;">疲劳管理</text>
				</view>
			</view>
			<view class="load-popup-keyboard">
				<view class="row" v-for="row in [[1,2,3],[4,5,6],[7,8,9],['x',0,'ok']]" :key="row">
					<view class="key" v-for="key in row" :key="key" @click="handleLoadKey(key)">
						<template v-if="key==='x'">
							<img style="width: 40rpx; height: 40rpx;"
								src="https://img.js.design/assets/img/68344b54448da3bb2f0b3975.png#7aaff35ded37d00562680110d93e5f46"
								alt="" />
						</template>
						<template v-else-if="key==='ok'">
							<img style="width: 40rpx; height: 40rpx;"
								src="https://img.js.design/assets/img/68344d7e6ef735a473cd3d26.png#d48ba0c39ff163a3600b8c8b59a13096"
								alt="" />
						</template>
						<template v-else>{{ key }}</template>
					</view>
				</view>
			</view>



			<!-- 暂时！！！！！！！！！！ -->

			<!-- 暂时！！！{{isauto}}！！！！！！！ -->
			<view class="load-popup-right">
				<view class="load-popup-item" @click="auto_recognization"
					style="padding-left: 20rpx; background: rgba(240,240,240,1);">
					<view class="" style="">
						<view class="" v-if="!isauto"
							style="display: flex; align-items: center; border-radius: 100px;  background: rgba(204, 204, 204, 1); width: 32px; height: 14px;">
							<view class=""
								style="   border-radius: 50%; background: rgba(255, 255, 255, 1);   width: 12px; height: 12px;">

							</view>
							<view class=""
								style="margin-left: 7rpx;  display: flex;  align-items: center;   color: white; font-size: 10rpx;">
								PRO
							</view>
						</view>
						<view class="" v-if="isauto"
							style="display: flex; justify-content: flex-end; align-items: center; border-radius: 100px; background: rgba(110, 88, 170, 1); width: 32px; height: 14px; ">

							<view class=""
								style="margin-right: 5rpx; display: flex;  align-items: center;   color: white; font-size: 10rpx;">
								PRO
							</view>
							<view class=""
								style=" border-radius: 50%;  background: rgba(255, 255, 255, 1);   width: 12px; height: 12px;">

							</view>

						</view>
					</view>

					<text class="desc"
						style="margin-top: 20rpx; font-size: 10rpx; display: flex; margin-right: 20rpx; justify-content: center;">自动识别当日1RM</text>
				</view>



				<!-- 隐藏 -->
				<view class="load-popup-item editable" v-if="showsmw==false" style="background: rgba(240, 240, 240, 1);"
					:class="{active: loadInputTarget==='history_burden'}">

				</view>
				<view class="load-popup-item editable" v-if="showsmw==false" style="background: rgba(240, 240, 240, 1);"
					:class="{active: loadInputTarget==='burden_index'}">

				</view>




				<!-- 显示 -->
				<view class="load-popup-item editable" v-if="showsmw==true"
					:class="{active: loadInputTarget==='history_burden'}" @click="setLoadInput('history_burden')">
					<view class="" style="display: flex; justify-content: center; ">
						{{ history_burden }}
					</view>


					<text class="desc" style="font-size: 10rpx; display: flex; justify-content: center;">历史大负荷</text>
				</view>
				<view class="load-popup-item editable" v-if="showsmw==true"
					:class="{active: loadInputTarget==='burden_index'}" @click="setLoadInput('burden_index')">
					<view class="" style="display: flex; justify-content: center; ">
						{{ burden_index }}
					</view>

					<text class="desc" style="font-size: 10rpx; display: flex; justify-content: center;">个数</text>
				</view>
				<view class="load-popup-item editable" :class="{active: loadInputTarget==='auto_lrm'}">
					<view class="" style="display: flex; justify-content: center; ">
						{{ auto_lrm }}
					</view>

					<text class="desc" style="font-size: 10rpx; display: flex; justify-content: center;">粗略1RM</text>
				</view>
			</view>
		</view>
		<VersionHeader :version_control="isVersionControl" />
		<view class="loss_title">
			速度损失
		</view>
		<view class="progress" style="">
			<view class="slider-bar">

				<!-- 红色空 -->
				<view v-if="v_loss!=100" class="" :style="{ width: red_none }" style="
				border-radius: 8px 0px 0px 8px;
				  height: 12px; border: 1px solid rgba(212, 48, 48, 0.6);  "></view>

				<!-- 红色覆盖 -->
				<view v-if="v_loss>40" class="" style="
				   height: 12px; border-radius: 8px 0px, 0px, 8px; background: rgba(212, 48, 48, 0.6);  "
					:style="{ width: red_cover }"></view>


				<!-- 紫色覆盖 -->
				<view class="" style="
				height: 12px; background: rgba(110, 88, 170, 1);
				width: 20%;"></view>

				<!-- 绿色覆盖 -->
				<view v-if="v_loss<20" class="" :style="{ width: green_cover }"
					style="height: 12px; background: rgba(165, 214, 63, 0.8);"></view>

				<!-- 绿色空 -->
				<view v-if="v_loss!=0" class="" :style="{ width: green_none }"
					style="border-radius: 0px 8px 8px 0px;  height: 12px; border: 1px solid rgba(165, 214, 63, 0.8);">
				</view>

				<view class="circle" :style="{ right: circlePosition , border:circle}"></view>
			</view>
			<view class="labels">
				<text style="">偏高</text>
				<text>合适</text>
				<text style="margin-right: 20rpx;">偏低</text>
			</view>
		</view>


		<!-- <view class="">
			{{temp_tip}}
		</view> -->
		<view class="grid-container" :style="{ gridTemplateRows: visibleIndices.length <= 2 ? '1fr' : '1fr 1fr' }">
			<view v-for="(index, indexKey) in visibleIndices" :key="indexKey" class="grid-item"
				style="align-items: center; ">
				<view class="index" style="">
					<view class="value" style="">
						{{index.value}}
					</view>
					<view class="unit">
						{{index.unit}}
					</view>
				</view>
				<view class="name">{{index.name}}
				</view>
			</view>
		</view>
		<view class="bar">
			<view class="title">
				<view class="">
					VBT数据面板
				</view>
				<view class="group-menu-anchor" @click.stop="showGroupMenu = true">
					{{ group === 0 ? '热身' : `第${group}组` }}
					<view class="group-menu" v-if="showGroupMenu">
						<view class="group-menu-item">热身</view>
						<view class="group-menu-item danger">删除本组</view>
					</view>
				</view>
			</view>
			<view class="small_title">
				展示当日特定动作训练个数、平均速度数据
			</view>
			<view class="echart_box">
				<l-echart ref="chartRef" @finished="initChart"></l-echart>
			</view>
		</view>
		<view class="tips">
			<view class="img">
				<img class="img"
					src="https://img.js.design/assets/img/67a58b3c06e8f15e94239f62.png#b165487345845ac6d3034c267f530967"
					alt="" />
			</view>
			<view class="content">
				{{tips}}
			</view>
		</view>
		<view class="bottom" style="position: absolute;">
			<view class="bottom-lr">
				<view class="" @click="showLoadPopupFn">
					<view class="value_unit" style="margin-bottom: 10rpx;">
						<view class="value">
							{{burden}}
						</view>
						<view class="unit">
							kg
						</view>
					</view>
					<view class="name" style="margin-left: 2rpx; margin-bottom: -12rpx;">
						负荷
					</view>
				</view>

				<view class="more-menu-anchor" @click.stop="showMenuPopup">
					<img src="https://img.js.design/assets/img/6834245aae72b5fd97af91d4.png#9810b1290b9d7784cc80d0105000c2a7"
						alt="" />
					<view class="small_title" style="font-size: 22rpx; margin-left: 6rpx;  margin-top: 5rpx;">
						更多
					</view>
				</view>
			</view>

			<view class="button" :style="{ background: !isStart ? '#fff' : 'rgba(110, 88, 170, 1)' }"
				@click="isStart ? stop() : start()">
				<img v-if="isStart" src="../../static/index/pause.png" alt="" style="width: 40rpx; height: 40rpx;" />
				<img v-else src="../../static/index/start.png" alt=""
					style="margin-left: 6rpx; width: 40rpx; height: 40rpx;" />
			</view>
		</view>
		<Countdown ref="countdownRef321" :type="'321'" @end="onCountdown321End" />
		<Countdown ref="countdownRef54321" :type="'54321'" @end="onCountdown54321End" />
		<view class="mask" v-if="showGroupMenu" @click="closeAllModals"></view>
		<!-- 通用弹窗 -->
		<view v-if="showTestModal">
			<view class="mask" @click="handleClose"></view>
			<view class="common-modal">
				<view class="common-modal-title" v-if="modalType=='description'">说明</view>
				<view class="common-modal-title" v-else>提示</view>
				<view class="common-modal-content" v-if="modalType === 'main'">
					{{ v0 ? '您已有该动作下个人专属1RM测试基准，是否前往测试今日1RM？' : '您目前没有该动作下的个人专属1RM测试基准,是否前往测试?' }}
				</view>
				<!-- 		    <view class="common-modal-content" v-else>
				目前没有该动作下您的1RM测试记录，建议开启自动识别或前往1RM测试区进行测试
		    </view> -->
				<view class="common-modal-actions" :class="modalType === 'main' ? 'actions-row' : 'actions-col'"
					v-if="modalType === 'main'">
					<!-- <button class="btn-cancel" @click="v0 ? '' : handleCancel">取消</button> -->
					<button class="btn-cancel" @click="handleCancel">取消</button>

					<button class="btn-confirm" @click="goToTest">
						前往
						<span class="pro-badge">PRO</span>
					</button>
				</view>
				<view class="common-modal-tips" style="font-size: 28rpx;" v-if="modalType === 'cancel'">
					目前没有该动作下您的1RM测试记录，建议开启自动识别或前往1RM测试区进行测试
				</view>
				<view class="" v-if="modalType=== 'description' ">
					<view class="" v-for="item in descriptionOptions" style="display: flex; align-items: center; width: 600rpx;
						height: 96rpx; border-radius: 10px; background: rgba(255, 255, 255, 1); margin: 20rpx auto;">
						<view class="" style="display: flex; align-items: center; ">
							<view class=""
								style="margin: auto 20rpx;  width: 430rpx; display: flex; align-items: center; font-size: 20rpx; color: rgba(0, 0, 0, 1);">
								{{item.label}}
							</view>
							<view class="">
								<view class=""
									style="display: flex; justify-content: center; margin-bottom: 5rpx; font-size: 40rpx; color: rgba(110, 88, 170, 1); ">
									{{item.val}}
								</view>
								<view class=""
									style="white-space: nowrap; font-size: 12rpx; color: rgba(124, 124, 126, 1);">
									{{item.unit}}
								</view>
							</view>

						</view>
					</view>
				</view>
				<view class="" v-if="modalType=='description'" @click="cancel_description"
					style="margin-bottom: 20rpx; color: rgba(110, 88, 170, 1); font-size: 30rpx;  display: flex; justify-content: center; margin-top: 80rpx;">
					已了解
				</view>
				<view class="common-modal-actions actions-col" v-if="modalType === 'cancel'">
					<view v-for="item in modalOptions" :key="item.label" class="modal-list-item"
						@click="handleOptionClick(item.action)">
						<view class="modal-list-label">
							<text style="font-size: 28rpx;">{{ item.label }}</text>
							<span v-if="item.pro" class="pro-badge-list">PRO</span>
						</view>
						<view class="modal-list-arrow" style="margin-bottom: 10rpx;">
							<img class="modal-list-arrow"
								src="https://img.js.design/assets/img/6839c50e448da3bb2fe6dce0.png#6ff8b8aab777cad9473bdc8939e8c728"
								alt="" />
						</view>
						<!-- <view class="modal-list-arrow" >&gt;</view> -->
					</view>

				</view>
				<view class="common-modal-tips" v-if="modalType === 'cancel'">
					测试过程仅需两分钟，点击"都不"后默认使用您的主观极限重量作为1RM
				</view>
			</view>
		</view>
	</scroll-view>
</template>
<script>
	import {
		request
	} from '@/utils/request.js'
	import VersionHeader from '@/components/version-header/version-header.vue';
	import VersionCanvas from '@/components/version-canvas/version-canvas.vue';
	import Countdown from "@/components/countdown/countdown.vue";
	import VueEvent from '../../VueEvent';
	// import request from '../../apis/vbt.js';
	import * as echarts from "@/pagesTool/static/echarts.min.js";
	import cal from '../../cal/vbt.js';
	import request_new from '../../apis/vbt.js';
	export default {
		data() {
			return {
				temp_tip: '111',
				showMask: false, // 控制遮罩层显示/隐藏
				showMenu: false, // 控制菜单弹窗显示/隐藏
				showLoadPopup: false, // 控制负荷弹窗显示
				flag_gaowei: false,
				trainWay: '', // 添加训练方式
				actionOptions: [{
						name: '深蹲',
						value: '1'
					},
					{
						name: '卧推',
						value: '2'
					},
					{
						name: '硬拉',
						value: '3'
					},
					{
						name: '俯身划船',
						value: '4'
					},
					{
						name: '高翻',
						value: '5'
					},
					{
						name: '杠铃推肩',
						value: '6'
					}
				],
				isVersionControl: false,
				indices: [{
						name: '平均速度',
						value: 0,

						unit: 'm/s',
						show: true

					},
					{
						name: '峰值速度',
						value: 0,
						unit: 'm/s',
						show: true

					},
					{
						name: '平均功率',
						value: 0,
						unit: 'w',
						show: true

					},
					{
						name: '峰值功率',
						value: 0,
						unit: 'w',
						show: true
					},
				],
				isFree: false,

				aim: VueEvent.sharedData.aim,
				action: VueEvent.sharedData.action,
				isStart: false,
				pinlv: 200,
				temp: [],
				counting: 0,
				history: [],
				stringtxt: "",
				filePath: '',
				//////////////////
				isVersionControl: false, // 控制按钮样式的状态
				measured_acceleration_y: [],
				measured_acceleration_x: [],
				measured_acceleration_z: [],
				angular_velocity_y: [],
				angular_velocity_x: [],
				angular_velocity_z: [],
				audioContext: null, // 音频上下文
				maxDataLength: 10000, // 定义数组最大长度，可根据实际需求调整
				showCircle: false, // 控制倒计时圆圈是否显示
				countdown: 3, // 倒计时初始数字
				// simple和professional的button颜色
				accelarateData: [
					0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
					0,
					0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
					0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
					0,
					0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
					0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
				],
				n_base: 0,
				local_g: 0,
				intervalId1: null, // 用于存储定时器ID
				tips: '等待开始中...',
				version: false,
				intervalId: null, // 用于存储定时器ID
				options_train_target: ['增肌', '增强力量', '提升爆发力'],
				options_train_action: ['深蹲', '卧推', '硬拉'],
				options_target: {
					'增肌': 0,
					'增强力量': 1,
					'提升爆发力': 2,
				},
				options_action: {
					'深蹲': 0,
					'卧推': 1,
					'硬拉': 2,
					'俯身划船': 3,
					'高翻': 4,
					'杠铃推肩': 5
				},
				rm: '0',
				burden: '0',
				sub_tips: false,
				r: 0, // 计时器的秒数
				timer: null, // 用来存储定时器ID，方便停止
				// isMuted: VueEvent.sharedData["isMuted"], // 初始为非静音

				arrs: [{
						text: '平均速度(m/s)',
						value: 0
					},
					{
						text: '峰值速度（m/s）',
						value: 0
					},
					{
						text: '平均功率(W)',
						value: 0
					},
					{
						text: '峰值功率(W)',
						value: 0
					}
				],
				v_loss: 10,
				group: 0,
				index: 0,
				burden_Modal: false,
				check_burden: false,
				test_flag: 0,
				ti: "",
				measured_acceleration_x: [],
				measured_acceleration_y: [],
				measured_acceleration_z: [],
				alpha: [],
				beta: [],
				gamma: [],
				local_gg: 0,
				countdownStep: 0, // 控制倒计时流程
				gaowei_status: false,
				speed_max: 0,
				v1: 0,
				v2: 0,


				// 速度下限
				a: [0.63, 0.49, 0.35, 0.7],
				// 速度上限
				b: [0.9, 0.63, 0.49, 0.9],
				// 速度损失下限
				c: [1000, 20, 20, 40],
				// 速度损失上限
				d: [10, 30, 30, 50],
				// 个数下限
				e: [3, 3, 7, 12],
				// 个数上限
				f: [6, 11, 7, 18],
				// 上肢 0  下肢 1
				up_down_action_options: [1, 0, 1, 0, 1, 0, 0, 0, 1, 1],
				loadType: '增肌',
				load1RM: 105,
				loadWeight: 65,
				loadRIR: 'RIR',
				loadInputTarget: '',
				isauto: false,
				history_burden: 80,
				burden_index: 0,
				auto_lrm: 10,
				mw_options: [0, 1, 0.95, 0.93, 0.90, 0.87, 0.85, 0.83, 0.80, 0.77, 0.75, 0.70, 0.67],
				fourteen_max_avg_v: 0,
				three_max_avg_v: 0,
				two_max_avg_v: 0,
				cal_burden_arg: 0.35,
				first_burden: 0,
				second_burden: 0,
				third_burden: 0,
				// 通用最小速度阈值
				y_to_x_options: [0.3, 0.17, 0.15, 0.40, 0.3, 0.19, 0.47, 0.19, 0.15, 0.15],
				aim_name_options: ['爆发', '增肌', '力量', '耐力'],
				aim_name: '',
				aim_arg_options: [0.59, 0.75, 0.85, 0.56],
				check_left_two: false,

				chartData: [],
				chartOptions: {
					grid: {
						left: 0,
						right: 10,
						top: 10,
						bottom: 10,
						containLabel: true
					},

					xAxis: {
						data: [1, 2, 3, 4, 5, 6],

						axisLabel: {
							color: 'rgba(124, 124, 126, 0.5)',
							// color: ,
							fontSize: 13
						},
						axisTick: {
							show: false // 将刻度线设置为不显示
						},
						axisLine: { // 添加x轴轴线配置
							show: true, // 显示轴线
							lineStyle: {
								color: 'rgba(124, 124, 126, 0.5)',
							}
						}
					},
					yAxis: {
						show: true,
						min: 0,
						max: 2,
						splitLine: {
							lineStyle: {
								color: '#eee',
								type: 'dashed'
							}
						},
						axisLine: {
							show: true,
							lineStyle: {
								color: 'rgba(124, 124, 126, 0.5)',
							}
						},
						axisLabel: {

							color: 'rgba(124, 124, 126, 0.5)',
							fontSize: 13
						}
					},

					series: [{
						name: '训练容量',
						type: 'bar',
						barWidth: '48%',
						itemStyle: {
							color: 'rgba(110, 88, 170, 0.5)',
						},
						label: {
							show: true,
							position: 'top',
							color: 'rgba(110, 88, 170, 0.5)',
							fontSize: 14,
							formatter: function(params) {
								return params.value;
							}
						},
						data: []
					}]
				},
				showGroupMenu: false,
				firstLoadPopup: true,
				showTestModal: false,
				modalType: 'description', // 'none'什么都没有   'main' 主弹窗，'cancel' 取消后的弹窗  'description'说明弹窗
				modalOptions: [{
						label: '自动识别',
						pro: true,
						action: 'auto'
					},
					{
						label: '前往测试',
						pro: true,
						action: 'goto'
					},
					{
						label: '都不',
						pro: false,
						action: 'none'
					}
				],
				descriptionOptions: [{
						label: '这里填写您在此动作下曾经做过的较大重量',
						val: '65',
						unit: '历史大重量/kg'
					},
					{
						label: '这里填写该动作下此重量下能做的极限个数',
						val: '6',
						unit: '该负荷对应个数'
					},
					{
						label: '估算1RM仅为初次训练提供重量匹配参考，仅生效一次，后续系统将通过实际训练表现重新评估您的真实1RM，该过程与当前估值无关。',
						val: '105',
						unit: '估算1RM/kg'
					},
				],
				v0: '',
				slrm: 0,
				clrm: 0,
				smw: 0,
				showsmw: true,
			}
		},
		onShow() {
			this.initChart();
			console.log("v_loss", this.v_loss)
			console.log("modalType", this.modalType)
		},
		computed: {
			// ?? 计算属性，保证 isMuted 自动更新
			isMuted() {
				return VueEvent.sharedData.isMuted;
			},
			red_none() {
				if (this.v_loss > 40) {
					let percentage = 100 - this.v_loss;
					// console.log("red_none", percentage);
					return `${percentage}%`;
				}
				// console.log("red_none 60%");
				return "60%";
			},
			red_cover() {
				if (this.v_loss > 40) {
					let percentage = this.v_loss - 40;
					// console.log("red_cover", percentage);
					return `${percentage}%`;
				}
				// console.log("red_cover 0%");
				return "0%";
			},
			green_none() {

				if (this.v_loss < 20) {
					let percentage = this.v_loss;
					// console.log("green_none", percentage);
					return `${percentage}%`;
				}
				// console.log("green_none 20%");
				return "20%";
			},
			green_cover() {
				if (this.v_loss < 20) {
					let percentage = 20 - this.v_loss;
					// console.log("green_cover", percentage);
					return `${percentage}%`;
				}
				// console.log("green_cover 0%");
				return "0%";
			},
			circlePosition() {
				let percentage = this.v_loss - 2;
				return `${percentage}%`;
			},
			circle() {
				if (this.v_loss < 20) {
					return "2px solid rgba(165, 214, 63, 0.8)";
				} else if (this.v_loss < 40) {
					return "2px solid rgba(110, 88, 170, 1)";
				} else {
					return "2px solid rgba(212, 48, 48, 0.6)";
				}
			},
			visibleIndices() {
				return this.indices.filter(item => item.show);
			},
		},
		mounted() {
			// this.aim = VueEvent.sharedData.aim;
			// this.action = VueEvent.sharedData.action;
			this.leastSquaresRegression(20, 0.8, 45, 0.55, 65, 0.32);
			console.log("aim", this.aim);
			console.log("action", this.action);
			this.gaowei_status = false
			this.aim_name = this.aim_name_options[VueEvent.sharedData.aim]
			if (this.up_down_action_options[VueEvent.sharedData.action] == 0) {
				this.a = [0.51, 0.38, 0.26, 0.57]
				this.b = [0.75, 0.51, 0.38, 0.75]
			}
		},
		onHide() {
			this.stopRequest();
			VueEvent.stopListeningAccelerometer();
		},
		onUnload() {
			// 页面被销毁时执行
			// this.executeFunction();
			VueEvent.stopListeningAccelerometer();
		},
		methods: {
			solve_equation(x1, y1, x2, y2) {
				// 检查两点是否相同
				if (x1 === x2 && y1 === y2) {
					return [0, 0]
				}

				// 计算斜率 a
				let a = (y2 - y1) / (x2 - x1);

				// 计算截距 b
				let b = y1 - a * x1;

				return [a, b];
			},
			y_cal_x(y, a, b) {
				// 检查斜率 a 是否为零
				if (a === 0) {
					if (y === b) {
						return 0
					} else {
						return 0
					}
				}

				// 计算 x = (y - b) / a
				return ((y - b) / a).toFixed(2);
			},
			// 最小二乘法算回归直线方程
			leastSquaresRegression(x1, y1, x2, y2, x3, y3) {
				// 检查是否所有点都在垂直直线上（防止除以零）
				if (x1 === x2 && x2 === x3) {
					return [0, 0]
					// throw new Error('所有点在垂直直线上，无法计算回归直线');
				}

				// 计算 x 和 y 的平均值
				const xMean = (x1 + x2 + x3) / 3;
				const yMean = (y1 + y2 + y3) / 3;

				// 计算斜率 a 的分子和分母
				let numerator = 0;
				let denominator = 0;

				// 对每个点进行累加计算
				const points = [{
						x: x1,
						y: y1
					},
					{
						x: x2,
						y: y2
					},
					{
						x: x3,
						y: y3
					}
				];

				for (const {
						x,
						y
					}
					of points) {
					numerator += (x - xMean) * (y - yMean);
					denominator += (x - xMean) ** 2;
				}

				// 计算斜率 a
				const a = numerator / denominator;

				// 计算截距 b
				const b = yMean - a * xMean;
				console.log("回归结果a b", a, b)
				return [a, b];
			},
			check_before_two() {
				let dist = Math.abs(this.fourteen_max_avg_v - this.three_max_avg_v)
				let a = 0
				let b = 0;
				if (this.group == 2) {
					if (dist >= 0.2) {
						// 两点确定直线 解方程
						this.temp_tip = this.temp_tip + '两点确定直线方程';

						console.log("x1,y1,x2,y2", this.first_burden, this.fourteen_max_avg_v, this.second_burden,
							this.three_max_avg_v);
						[a, b] = this.solve_equation(this.first_burden, this.fourteen_max_avg_v, this.second_burden,
							this.three_max_avg_v);
						a = a
						b = b
						console.log("a b", a, b)
						this.rm = this.y_cal_x(this.y_to_x_options[VueEvent.sharedData.action], a, b);
						console.log("精准1rm", this.rm)
						this.loadWeight = (this.rm * this.aim_arg_options[VueEvent.sharedData.aim]).toFixed(2);
						this.burden = (this.rm * this.aim_arg_options[VueEvent.sharedData.aim]).toFixed(2);
						console.log("算出负荷", this.burden)
						this.check_left_two = true;
					} else {
						this.temp_tip = this.temp_tip + '得回归得直线！'
						//做第二组，三个点算回归方程
						this.check_left_two = false;
					}
				} else if (this.group == 3) {
					console.log("x1,y1,x2,y2", this.first_burden, this.fourteen_max_avg_v,
						this.second_burden, this.three_max_avg_v,
						this.third_burden, this.two_max_avg_v);
					[a, b] = this.leastSquaresRegression(this.first_burden, this.fourteen_max_avg_v,
						this.second_burden, this.three_max_avg_v,
						this.third_burden, this.two_max_avg_v);
					a = a
					b = b
					console.log("a b", a, b)
					this.rm = this.y_cal_x(this.y_to_x_options[VueEvent.sharedData.action], a, b);
					console.log("精准1rm", this.rm)
					this.loadWeight = (this.rm * this.aim_arg_options[VueEvent.sharedData.aim]).toFixed(2);
					this.burden = (this.rm * this.aim_arg_options[VueEvent.sharedData.aim]).toFixed(2);
					console.log("算出负荷", this.burden)
				}

			},
			update_burden() {
				this.loadWeight = (this.auto_lrm * this.cal_burden_arg).toFixed(2)
				this.burden = (this.auto_lrm * this.cal_burden_arg).toFixed(2)
				let yu = Math.floor(this.burden / 5);
				console.log("burden", this.burden)
				console.log("yu", yu)
				console.log(Math.abs(this.burden - yu * 5), Math.abs(this.burden - (yu + 1) * 5))
				if (this.burden < 30) {
					this.burden = 20;
					this.loadWeight = 20;
				} else if (Math.abs(this.burden - yu * 5) <= Math.abs(this.burden - (yu + 1) * 5)) {
					console.log("left big")
					this.burden = yu * 5;
					this.loadWeight = yu * 5;
				} else {
					console.log("right big")
					this.burden = (yu + 1) * 5;
					this.loadWeight = (yu + 1) * 5;
				}
			},
			auto_recognization() {
				if (this.isauto == false) {
					let ismember = uni.getStorageSync('userInfo').isMember
					console.log("ismeber", ismember)
					if (ismember == false) {
						uni.showToast({
							title: "请充值会员解锁特权",
							icon: "none",
						});
						return
					}
				}
				this.isauto = !this.isauto
			},
			async initChart() {
				const chart = await this.$refs.chartRef.init(echarts);
				// 初始化时显示横纵坐标但不显示任何柱子和数字
				this.chartOptions.xAxis.data = [1, 2, 3, 4, 5, 6];
				this.chartOptions.series[0].data = [null, null, null, null, null, null];
				this.chartOptions.series[0].label.show = false;
				chart.setOption(this.chartOptions);
			},
			toggleMute() {
				VueEvent.changeVoice(); // ?? 切换静音状态
				console.log("现在是：", VueEvent.sharedData.isMuted);
				console.log("现在是：", this.isMuted);
			},
			onPickerChange_train_target(event) {
				const {
					value
				} = event.detail;
				this.aim = this.options_train_target[value];
				this.check_burden_value();
			},

			onPickerChange_train_action(event) {
				const {
					value
				} = event.detail;
				this.action = this.options_train_action[value];
				this.check_burden_value();
			},
			onFocus() {
				if (this.trainWay === '针对性训练') {
					if (this.aim === '' || this.action === '' || this.rm === '' || this.burden === '') {
						uni.showModal({
							title: '提示',
							content: '请先完善信息',
							showCancel: false,
							confirmText: '我已了解',
							success: (res) => {
								if (res.confirm) {
									console.log('用户点击了确定');
								}
							}
						});
						return true;
					}
				} else {
					if (this.aim === '' || this.action === '') {
						uni.showModal({
							title: '提示',
							content: '请先完善信息',
							showCancel: false,
							confirmText: '我已了解',
							success: (res) => {
								if (res.confirm) {
									console.log('用户点击了确定');
								}
							}
						});
						return true;
					}
				}
				return false;
			},
			onInputFocus() {
				console.log(this.aim, this.action, this.rm);
				if (this.aim === '' || this.action === '' || this.rm === '') {
					if (!this.burden_Modal) {
						this.burden_Modal = true;
						uni.showModal({
							title: '提示',
							content: '请先完善训练目的，训练动作和1rm的信息',
							showCancel: false,
							confirmText: '我已了解',
							success: (res) => {
								if (res.confirm) {
									console.log('用户点击了确定');
								}
								// 当弹窗关闭后，重置标志位，以便下次还能触发
								this.burden_Modal = false;
							}
						});
					}
				}
				return false;
			},
			savetxt() {
				const fs = uni.getFileSystemManager();

				// 假设 this.temp 是一个数组
				let content = this.stringtxt; // 将数组转换为字符串

				// 使用 USER_DATA_PATH 作为临时存储路径
				const tempFilePath = `${uni.env.USER_DATA_PATH}/result.docx`;

				// 先写入临时路径
				fs.writeFile({
					filePath: tempFilePath,
					data: content,
					encoding: 'utf8',
					success: () => {
						// console.log('文件保存到临时路径成功！', tempFilePath);

						// **使用 saveFile 将文件转存到用户可访问的位置**
						uni.saveFile({
							tempFilePath: tempFilePath, // 从临时路径保存
							showMenu: true, // 允许出现分享功能
							success: (res) => {
								// console.log('文件已存入用户可访问路径:', res.savedFilePath);

								// **确保文件路径合法并且可以共享**
								const savedFilePath = res.savedFilePath;

								uni.openDocument({
									filePath: savedFilePath,
									// fileType: 'pdf', // 指定文件的格式
									showMenu: true, // 允许出现分享功能
									success: r => {
										console.log(r)
									},
									fail: openError => {
										console.log('打开失败: ', openError)
									}
								})


							},
							fail: (err) => {
								console.error('保存文件到用户可访问路径失败：', err);
							}
						});
					},
					fail: (err) => {
						console.error('文件写入失败：', err);
					}
				});
			},

			check_bd_value() {
				if (isNaN(this.burden)) {
					uni.showToast({
						title: '负荷只能为数字，请重新输入',
						icon: 'none'
					})
					this.burden = '';
					return;
				}
			},
			check_action_value(e) {
				let index = e.detail.value
				this.action = this.actionOptions[index].name // 更新选中的值
				console.log(this.options_action[this.action])
				console.log("action!", this.action)
			},
			check_burden_value() {
				if (isNaN(this.rm)) {
					uni.showToast({
						title: '1RM只能为数字，请重新输入',
						icon: 'none'
					})
					this.rm = '';
					return;
				}
				if (this.aim !== '' && this.action !== '' && this.rm !== '') {
					if (!this.check_burden) {
						this.check_burden = true;
						var suggest = cal.get_suggest(this.options_target[this.aim] - 1, this.options_action[this.action] -
							1, this.rm);
						console.log("建议信息：", suggest);
						uni.showModal({
							title: '提示',
							content: '建议负重' + suggest[0].toFixed(1) + 'kg-' + suggest[1].toFixed(1) + 'kg',
							showCancel: false,
							confirmText: '我已了解',
							success: (res) => {
								if (res.confirm) {
									// console.log('用户点击了确定');
									// 当弹窗关闭后，重置标志位，以便下次还能触发
									this.check_burden = false;
								}
							}
						});

					}

				}
			},
			stop() {

				if (this.isStart) {

					uni.showModal({
						// title: '1RM是什么?',
						content: '停止训练后将清除数据',
						showCancel: true,
						confirmText: '确定',
						success: (res) => {
							if (res.confirm) {
								// 用户点击了确定
								this.isStart = false;
								this.gaowei_status = false
								// this.addlast();
								this.stopRequest();
								this.flag_gaowei = false
								this.openFile();
								// this.savetxt();
								
								// 停止一组训练
								// 默认动作映射表
								
								console.log("到达世界最高层")
								console.log("更新前本地缓存",VueEvent.sharedData.train_record)
								for (let i = 0; i < VueEvent.sharedData.train_record.length; i++) {
									let action_mapp = [4,0,1000,1,1000,2,1000,1000,1000,1000]
									let tpp = action_mapp[VueEvent.sharedData.action]
									if(tpp==1000) continue 
									if(VueEvent.sharedData.train_record[i].trainBody==tpp){
										VueEvent.sharedData.train_record[i].trainData[this.group].lrm = this.rm
										VueEvent.sharedData.train_record[i].trainData[this.group].num = this.index
									}
									
								}
								console.log("更新后本地缓存",VueEvent.sharedData.train_record)

								this.group = this.group + 1;

								if (this.group == 1) {
									this.temp_tip = "热身组前14个平均速度" + this.fourteen_max_avg_v.toString();
								} else if (this.group == 2) {
									this.temp_tip = "第一组前3个平均速度" + this.three_max_avg_v.toString();
								}


								if (this.group == 2) {
									this.check_before_two();
								} else if (this.check_left_two == false && this.group == 3) {
									this.check_before_two()
								}
								this.index = 0;
								this.indices[0].value = 0;
								this.indices[1].value = 0;
								this.indices[2].value = 0;
								this.indices[3].value = 0;
								// this.updateChart();
							} else if (res.cancel) {

							}
						},
					});

				} else {
					uni.showToast({
						title: '请先点击开始~',
						icon: 'none'
					})
					return;
				}

			},
			start() {
				if (this.isStart) {
					uni.showToast({
						title: '正在进行中~',
						icon: 'none'
					})
					return;
				} else {
					if (this.onFocus() === true) {
						return;
					}
					this.isStart = true;
					this.chartData = [];
					VueEvent.init_Accelerometer();
					VueEvent.startListeningAccelerometer();
					this.speed_max = 0
					this.v_loss = 0
					console.log("展示倒计时圈");
					this.startAllCountdown();
					if (this.group == 1) {
						this.cal_burden_arg = 0.75
						this.update_burden()
						this.temp_tip = this.temp_tip + '负荷' + this.burden.toString();
						this.second_burden = this.burden
					} else if (this.group == 0) {
						this.cal_burden_arg = 0.35
						this.update_burden()
						this.temp_tip = this.temp_tip + '负荷' + this.burden.toString();
						this.first_burden = this.burden
					} else if (this.group == 2) {
						this.cal_burden_arg = 0.55
						this.update_burden()
						this.temp_tip = this.temp_tip + '负荷' + this.burden.toString();
						this.third_burden = this.burden
					}
					// this.show_clock();
					// this.startRequest();
				}
			},
			addlast() {

				const fs = uni.getFileSystemManager();
				const dataToAppend = JSON.stringify(this.temp);
				const x = JSON.stringify(this.measured_acceleration_x);
				const y = JSON.stringify(this.measured_acceleration_y);
				const z = JSON.stringify(this.measured_acceleration_z);
				const alpha = JSON.stringify(this.alpha);
				const beta = JSON.stringify(this.beta);
				const gamma = JSON.stringify(this.gamma);
				// 追加写入文件
				fs.appendFile({
					filePath: this.filePath,
					data: "更新了" + "\n" +
						"measured_acceleration_x\n" + x + '\n' +
						"measured_acceleration_y\n" + y + '\n' +
						"measured_acceleration_z\n" + z + '\n' +
						"alpha\n" + alpha + '\n' +
						"beta\n" + beta + '\n' +
						"gamma\n" + gamma + '\n' +
						"acceleration_data\n" + dataToAppend + '\n',
					encoding: 'utf8',
					success: () => {
						console.log("写入文件成功！");
					},
					fail: (err) => {
						console.error('写入文件失败', err);
					},
				});
			},
			openFile() {
				uni.openDocument({
					filePath: this.filePath,
					fileType: 'docx',
					showMenu: true, // 允许出现分享功能
					success: (res) => {
						console.log('文件打开成功');
					},
					fail: (err) => {
						console.error('文件打开失败', err);
					},
				});
			},
			numberToChinese(numStr) {
				const chineseNumbers = ['零', '一', '二', '三', '四', '五', '六', '七', '八', '九'];
				const decimalPoint = '点';

				let result = '';
				for (let i = 0; i < numStr.length; i++) {
					const char = numStr[i];
					if (char === '.') {
						result += decimalPoint;
					} else if (/[0-9]/.test(char)) {
						result += chineseNumbers[parseInt(char)];
					}
				}
				return result;
			},



			async sendRequest() {
				let say_what = '';
				this.measured_acceleration_x = VueEvent.sharedData.measured_acceleration_x;
				this.measured_acceleration_y = VueEvent.sharedData.measured_acceleration_y;
				this.measured_acceleration_z = VueEvent.sharedData.measured_acceleration_z;
				this.alpha = VueEvent.sharedData.alpha;
				this.beta = VueEvent.sharedData.beta;
				this.gamma = VueEvent.sharedData.gamma;

				let res = cal.simple_update(
					VueEvent.sharedData.measured_acceleration_x,
					VueEvent.sharedData.measured_acceleration_y,
					VueEvent.sharedData.measured_acceleration_z,

					VueEvent.sharedData.alpha,
					VueEvent.sharedData.beta,
					VueEvent.sharedData.gamma,

					VueEvent.sharedData.aim,
					VueEvent.sharedData.action,
					this.rm,
					this.burden,
					this.index,
					this.local_gg,
					0.02
				);

				if (res.local_g != 0) {
					this.local_gg = res.local_g;
				}
				// console.log("结果是",res.flag)
				if (res.flag == true) {
					// console.log("删除索引是",res.del_index)
					VueEvent.del_Accelerometer(res.del_index);

					if (VueEvent.sharedData.action == 6 && this.gaowei_status == false) {
						return;
					}
					
					this.index = this.index + 1;
					
					// 计算v_loss
					if (this.index > 2) {
						if (((this.speed_max - res.averagy_v_value.toFixed(2)) * 100 / this.speed_max) < 0) {
							this.v_loss = 0;
						} else {
							this.v_loss = (this.speed_max - res.averagy_v_value.toFixed(2)) * 100 / this.speed_max;
						}

					} else {
						if (this.index == 1) {
							this.v1 = res.averagy_v_value.toFixed(2);
						} else if (this.index == 2) {
							this.v2 = res.averagy_v_value.toFixed(2);
						}
						this.v_loss = 0
						this.speed_max = Math.max(this.speed_max, res.averagy_v_value.toFixed(2));
					}
					if (this.group == 0 && this.index <= 14) {
						this.fourteen_max_avg_v = Math.max(this.fourteen_max_avg_v, res.averagy_v_value.toFixed(2))
					} else if (this.group == 1 && this.index <= 3) {
						this.three_max_avg_v = Math.max(this.three_max_avg_v, res.averagy_v_value.toFixed(2))
					} else if (this.group == 2 && this.index <= 2) {
						this.two_max_avg_v = Math.max(this.two_max_avg_v, res.averagy_v_value.toFixed(2))
					}
					console.log("本次的v_loss:", this.v_loss)
					this.indices[0].value = res.averagy_v_value.toFixed(2);
					this.indices[1].value = res.v_peak.toFixed(2);
					this.indices[2].value = res.averagy_power_value.toFixed(2);

					this.indices[3].value = res.power_peak.toFixed(2);

					let v_data = res.averagy_v_value.toFixed(2);
					let new_v_data = this.numberToChinese(v_data);




					// a 0.2   b  0.4
					if (this.index == 1) {
						if (this.v1 < this.a[VueEvent.sharedData.aim]) {
							say_what = "当前重量可能偏大"
							this.tips = '当前重量可能偏大';
						} else if (this.v1 > this.b[VueEvent.sharedData.aim]) {
							// await this.textToVoice("当前重量可能偏小");
							say_what = "当前重量可能偏小"
							this.tips = '当前重量可能偏小';
						}

					} else if (this.index == 2) {
						if (this.v1 < this.a[VueEvent.sharedData.aim] && this.v2 < this.a[VueEvent.sharedData.aim]) {
							// await this.textToVoice("当前重量确实偏大，请减少重量");
							say_what = "当前重量确实偏大，请减少重量"
							this.tips = '当前重量确实偏大，请减少重量';
						} else if (this.v1 > this.b[VueEvent.sharedData.aim] && this.v2 > this.b[VueEvent.sharedData
								.aim]) {
							// await this.textToVoice("当前重量确实偏小，请增加重量");
							say_what = "当前重量确实偏小，请增加重量"
							this.tips = '当前重量确实偏小，请增加重量';
						}
					} else {
						if (this.v_loss > this.d[VueEvent.sharedData.aim]) {
							if (this.index >= this.e[VueEvent.sharedData.aim]) {
								// await this.textToVoice("本组训练结束");
								say_what = "本组训练结束"
								this.tips = '本组训练结束';
							} else {
								// await this.textToVoice("本组训练结束,建议下一组减少重量");
								say_what = "本组训练结束,建议下一组减少重量"
								this.tips = '本组训练结束,建议下一组减少重量';
							}
						} else {
							if (this.index > this.f[VueEvent.sharedData.aim]) {
								// await this.textToVoice("本组训练结束,建议下一组增加重量");
								say_what = "本组训练结束,建议下一组增加重量"
								this.tips = '本组训练结束,建议下一组增加重量';
							} else {
								if (this.v_loss >= this.c[VueEvent.sharedData.aim]) {
									// await this.textToVoice("本组训练结束");
									say_what = "本组训练结束"
									this.tips = '本组训练结束';
								}
							}
						}
					}


					if (this.v_loss > 10) {
						say_what = say_what + "叮" + new_v_data + "米每秒"
					} else {
						say_what = say_what + new_v_data + "米每秒"
					}



					try {
						await this.textToVoice(say_what);
					} catch (error) {
						console.error("语音播报失败:", error);
					}

					this.chartData.push(Number(res.averagy_v_value.toFixed(2)));

					this.updateChart();
				}
			},


			startRequest() {
				console.log('start to post message');
				this.index = 0;
				this.v1 = 0
				this.v2 = 0
				if (this.intervalId) {
					return; // 如果定时器已经存在，防止重复点击
				}
				console.log("现在频率是", this.pinlv);
				// 使用 setInterval 设置定时器
				this.intervalId = setInterval(() => {
					this.sendRequest();
					// console.log('我发送了一次请求');
				}, this.pinlv); // 每隔400毫秒发送一次请求
			},



			// 清除发送请求的定时器
			stopRequest() {
				console.log('stop to post message');
				// VueEvent.init_Accelerometer();
				VueEvent.stopListeningAccelerometer();
				if (this.intervalId) {
					clearInterval(this.intervalId); // 清除定时器
					this.intervalId = null; // 重置定时器ID
				}
			},
			tips_1rm() {
				uni.showModal({
					title: '1RM是什么?',
					content: '1RM：以正确的技术所能举起一次最大重量\n\n填写后会自动为您计算本次训练的最佳负荷',
					showCancel: false,
					confirmText: '我已了解',
					success: (res) => {
						if (res.confirm) {
							console.log('用户点击了确定');
						}
					}
				});

			},
			gotoDefine() {
				uni.navigateTo({
					url: '/pagesExtra/define/define',
				});
			},
			goOneRm() {
				uni.switchTab({
					url: '/pages/jobOneRm/jobOneRm'
				});
			},

			/**
			 * 异步文本转语音并播放
			 * @param {string} text - 要转换为语音的文本
			 * @returns {Promise<WechatMiniprogram.InnerAudioContext>} 返回音频上下文的Promise
			 */
			async textToVoice(text) {
				return new Promise((resolve, reject) => {
					try {
						const systemInfo = wx.getSystemInfoSync();
						// console.log("当前设备系统：", systemInfo.platform);

						const pluginSI = requirePlugin("WechatSI");
						const innerAudioSI = wx.createInnerAudioContext();

						// 设置播放速率为1.5倍
						innerAudioSI.playbackRate = 1.3;
						// 设置音量为0.8（可以根据需要调整，范围0-1）
						innerAudioSI.volume = 1.0;

						// 1. 文本转语音
						pluginSI.textToSpeech({
							lang: "zh_CN",
							tts: true,
							content: text,
							success: async (res) => {
								// console.log("TTS 返回的音频 URL:", res.filename);

								try {
									// 2. 下载音频文件
									const downloadRes = await new Promise((dlResolve,
										dlReject) => {
										const downloadTask = wx.downloadFile({
											url: res.filename,
											success: dlResolve,
											fail: dlReject
										});

										downloadTask.onProgressUpdate((
											progress) => {
											// console.log(
											// 	`下载进度: ${progress.progress}%`
											// );
										});
									});

									// console.log("下载成功，临时路径:", downloadRes.tempFilePath);

									// 3. 设置音频源并播放
									innerAudioSI.src = downloadRes.tempFilePath;
									await innerAudioSI.play();

									// 设置播放结束回调
									innerAudioSI.onEnded(() => {
										// console.log("语音播放完毕");
										innerAudioSI.stop();
										innerAudioSI.destroy();
									});

									resolve(innerAudioSI);

								} catch (downloadError) {
									console.error("下载音频失败:", downloadError);
									innerAudioSI.destroy();
									reject(downloadError);
								}
							},
							fail: (ttsError) => {
								console.log("TTS 失败:", ttsError);
								if (systemInfo.platform === "ios") {
									console.log("iOS 设备上 TTS 失败");
								}
								reject(ttsError);
							}
						});

					} catch (error) {
						console.error("textToVoice 发生错误:", error);
						reject(error);
					}
				});
			},
			stop_group() {
				if (!this.isStart) {
					uni.showToast({
						title: '请先点击开始~',
						icon: 'none'
					})
					return;
				}
				uni.showModal({
					// title: '1RM是什么?',
					content: '确定结束本组训练吗',
					showCancel: true,
					confirmText: '确定',
					success: (res) => {
						if (res.confirm) {
							// 增加组的计数
							this.stopRequest();
							if (this.index !== 0) {
								this.group = this.group + 1;
							} else {
								uni.showToast({
									title: '个数为0不计入组数',
									icon: 'none'
								})
							}
							this.index = 0;
							VueEvent.init_Accelerometer();
							VueEvent.stopListeningAccelerometer();
							this.isStart = false;
							// 初始化 r 为 1，每次点击重新开始计时
							this.r = 1;

							// 更新显示提示信息
							this.updateTips();

							// 启动计时器，每隔一秒更新一次 r
							if (this.timer) {
								clearInterval(this.timer); // 清除上一个定时器（防止重复计时）
							}
							this.startTimer();
						}
					},
				});

			},
			// 在methods中定义播放音频的函数
			playAudio(src) {
				const audioContext = uni.createInnerAudioContext(); // 创建音频上下文对象
				audioContext.src = src; // 设置音频源，替换为你的音频文件路径
				audioContext.autoplay = true; // 设置自动播放

				// 监听播放事件
				audioContext.onPlay(() => {
					console.log('音频开始播放');
				});

				// 监听播放错误事件
				audioContext.onError((res) => {
					console.log('音频播放出错：', res.errMsg);
				});

				// 监听播放完成事件
				audioContext.onEnded(() => {
					console.log('音频播放完毕');
				});

				// 播放音频
				audioContext.play();
			},
			// 创建文件
			createFile() {
				const fs = uni.getFileSystemManager();
				fs.writeFile({
					filePath: this.filePath,
					data: '', // 初始内容为空
					encoding: 'utf8',
					success: (res) => {
						console.log('文件创建成功');
					},
					fail: (err) => {
						console.error('创建文件失败', err);
					},
				});
			},
			show_clock() {
				if (this.timer) {
					clearInterval(this.timer); // 清除上一个定时器（防止重复计时）
					this.countdown = 3; // 重置倒计时数字
				}

				this.tips = '等待开始中...';
				this.showCircle = true;
				var lst = VueEvent.sharedData.clock;
				console.log("音频地址是：", lst);
				var idx = 0;

				// 启动倒计时定时器
				const timer = setInterval(() => {
					if (this.countdown > 0) {
						// 每次倒计时数字更新前，立即播放对应的音频
						if (!this.isMuted) {
							this.playAudio(lst[idx]);
						}

						this.countdown--; // 更新倒计时数字
						idx++; // 更新音频索引
					} else {
						// 倒计时结束，播放"开始"语音
						if (!this.isMuted) {
							this.playAudio(lst[idx]);
						}

						clearInterval(timer); // 清除定时器
						this.countdown = 3; // 重置倒计时数字
						this.showCircle = false;
						// this.startRequest(); // 倒计时结束后，开始请求
					}
				}, 1000); // 每秒检查一次
			},
			async startAllCountdown() {
				this.countdownStep = 1;
				await this.$refs.countdownRef321.startCountdown();
			},
			onCountdown321End() {
				// 321倒计时结束后的自定义操作
				this.doSomethingAfter321().then(() => {
					// 如果需要高位下拉再进行54321倒计时

					if (VueEvent.sharedData.action == 6) {

						this.$refs.countdownRef54321.startCountdown();
					}
				});
			},
			onCountdown54321End() {
				// 54321倒计时结束后的自定义操作
				this.doSomethingAfter54321();
			},
			async doSomethingAfter321() {
				// 这里写321倒计时结束后的自定义操作
				this.startRequest();
				return Promise.resolve();
			},
			doSomethingAfter54321() {
				// 这里写54321倒计时结束后的自定义操作
				this.gaowei_status = true
				VueEvent.init_Accelerometer();

			},
			showMenuPopup() {
				this.showMask = true;
				this.showMenu = true;
			},
			closeAllModals() {
				this.showTestModal = false;
				this.showMask = false;
				this.showLoadPopup = false;
				this.showGroupMenu = false;
				this.modalType = 'none';
				this.showMenu = false
				console.log("当前是none")
			},
			hideMenu() {
				this.showMask = false;
				this.showMenu = false;
			},
			showLoadPopupFn() {
				this.showMask = true;
				if (this.firstLoadPopup == true) {

					this.firstLoadPopup = false
					this.showTestModal = true
					this.modalType = "description"
				} else {
					this.showLoadPopup = true

					this.loadInputTarget = '1RM';
					this.load1RM = this.rm || 0;
					this.loadWeight = this.burden || 0;


				}




			},
			hideLoadPopup() {
				this.showLoadPopup = false;
				this.rm = this.load1RM;
				this.burden = this.loadWeight;
			},
			setLoadInput(type) {
				this.loadInputTarget = type;
				// this.loadInputTarget = type === '1RM' ? '1RM' : 'weight';
			},
			handleLoadKey(key) {
				// if (!this.loadInputTarget) return;
				console.log("loadInputTarget", this.loadInputTarget);
				if (key === 'x') {
					if (this.loadInputTarget === '1RM') {
						this.load1RM = Math.floor(this.load1RM / 10);
					} else if (this.loadInputTarget === 'weight') {
						this.loadWeight = Math.floor(this.loadWeight / 10);
					} else if (this.loadInputTarget === 'burden_index') {
						this.burden_index = Math.floor(this.burden_index / 10);
					} else if (this.loadInputTarget === 'history_burden') {
						this.history_burden = Math.floor(this.history_burden / 10);
					} else if (this.loadInputTarget === 'auto_lrm') {
						this.auto_lrm = Math.floor(this.auto_lrm / 10);
					}
				} else if (key === 'ok') {
					// this.hideLoadPopup();
					this.auto_lrm = (this.history_burden / this.mw_options[this.burden_index]).toFixed(2);
					this.update_burden()
				} else {
					if (this.loadInputTarget === '1RM') {
						this.load1RM = this.load1RM === 0 ? key : ('' + this.load1RM + key) * 1;
					} else if (this.loadInputTarget === 'weight') {
						this.loadWeight = this.loadWeight === 0 ? key : ('' + this.loadWeight + key) * 1;
					} else if (this.loadInputTarget === 'burden_index') {
						this.burden_index = this.burden_index === 0 ? key : ('' + this.burden_index + key) * 1;
						if (this.burden_index > 12) {
							uni.showToast({
								title: '最大只能为12',
								icon: 'none'
							});
							this.burden_index = 0;
						}
					} else if (this.loadInputTarget === 'history_burden') {
						this.history_burden = this.history_burden === 0 ? key : ('' + this.history_burden + key) * 1;
					} else if (this.loadInputTarget === 'auto_lrm') {
						this.auto_lrm = this.auto_lrm === 0 ? key : ('' + this.auto_lrm + key) * 1;
					}
				}
			},
			showGroupMenu() {
				this.showGroupMenu = true;
			},
			updateChart() {
				if (!this.chartData.length) {
					this.chartOptions.series[0].label.show = false; // 初始状态下不显示标签
					this.chartOptions.series[0].data = [null, null, null, null, null, null]; // 初始时不显示任何柱子
					this.chartOptions.xAxis.data = [1, 2, 3, 4, 5, 6]; // 横坐标正常显示
				} else {
					// 创建一个长度为6的数组，初始值都为0
					const displayedData = new Array(6).fill(0);

					// 如果数据超过6个，只取最新的6个
					const startIndex = Math.max(0, this.chartData.length - 6);
					const recentData = this.chartData.slice(startIndex);

					// 将实际数据填充到displayedData中
					recentData.forEach((value, index) => {
						displayedData[index] = value;
					});

					// 设置数据
					this.chartOptions.series[0].data = displayedData;
					this.chartOptions.series[0].label.show = true; // 有数据时显示标签

					// 设置每个柱子的颜色
					this.chartOptions.series[0].itemStyle = {
						color: function(params) {
							// 获取当前数据的索引
							const currentIndex = params.dataIndex;
							// 获取实际数据的长度
							const dataLength = recentData.length;

							// 如果是最后一个数据，使用深色
							if (currentIndex === dataLength - 1) {
								return 'rgba(110, 88, 170, 0.85)';
							}
							// 其他柱子使用浅色
							return 'rgba(110, 88, 170, 0.5)';
						}
					};

					// 设置标签颜色与柱子颜色一致
					this.chartOptions.series[0].label.color = function(params) {
						const currentIndex = params.dataIndex;
						const dataLength = recentData.length;

						if (currentIndex === dataLength - 1) {
							return 'rgba(110, 88, 170, 0.85)';
						}
						return 'rgba(110, 88, 170, 0.5)';
					};

					// 计算横坐标标签
					const startLabel = startIndex + 1;
					this.chartOptions.xAxis.data = Array.from({
						length: 6
					}, (_, i) => startLabel + i);
				}
				if (this.$refs.chartRef) {
					this.$refs.chartRef.setOption(this.chartOptions, true);
				}
			},
			handleCancel() {
				this.modalType = 'cancel';
				if (this.v0 == -1) {
					// 无v0
					if (this.slrm != 0) {
						// 有slrm
						this.rm = this.slrm
						this.load1RM = this.slrm
						this.showMask = false
					} else {
						// 无slrm
						this.showTestModal = true;
						this.modalType = 'cancel'
					}
				} else {
					//有v0 点了取消
					this.load1RM = this.clrm
					this.rm = this.clrm
				}

			},
			handleClose() {
				this.showTestModal = false;
				this.modalType = 'main';
				console.log("当前是main2")
			},
			goToTest() {
				let ismember = uni.getStorageSync('userInfo').isMember;
				console.log("ismember", ismember);
				if (ismember == false) {
					uni.showToast({
						title: "请充值会员解锁特权",
						icon: "none",
					});
				} else {
					if (this.v0 == -1) {
						// 点了前往,没有v0,去1rm复杂版
						uni.navigateTo({
							url: "/pagesTool/jobComplexTestCommon/jobComplexTestCommon",
						});
					} else {
						// 点了前往,有v0,去1rm复杂版

						uni.navigateTo({
							url: "/pagesTool/jobComplexTestCommon/jobComplexTestCommon",
						});
					}

				}
			},
			async handleOptionClick(action) {
				if (action === 'auto') {
					// 自动识别
					let ismember = uni.getStorageSync('userInfo').isMember;
					console.log("ismember", ismember);
					if (ismember == false) {
						uni.showToast({
							title: "请充值会员解锁特权",
							icon: "none",
						});
						return;
					}
					this.isauto = true;
					this.showTestModal = false;
					this.showLoadPopup = true; // 显示数字键盘等内容
				} else if (action === 'goto') {
					let ismember = uni.getStorageSync('userInfo').isMember;
					console.log("ismember", ismember);
					if (ismember == false) {
						uni.showToast({
							title: "请充值会员解锁特权",
							icon: "none",
						});
						return;
					}
					this.closeAllModals(); // 关闭弹窗和掩膜
					this.isauto = true;
					this.showLoadPopup = true; // 显示数字键盘等内容
					uni.switchTab({
						url: '/pages/jobOneRm/jobOneRm'
					});
				} else if (action === 'none') {
					// this.closeAllModals(); // 关闭弹窗和掩膜
					// let res = await request_new.getsmw();
					console.log("当前动作！1", VueEvent.sharedData.map_action[this.action])
					let res = await request_new.getsmw({
						action: String(VueEvent.sharedData.map_action[this.action])
					});
					console.log("smw", res);

					if (res.status == 200) {
						if (res.data == null || res.data.smw == null) {
							this.showsmw = true
						} else {
							this.auto_lrm = res.data.smw
							this.showsmw = false
						}
					}
					this.showTestModal = false;
					this.showLoadPopup = true;
				}
			},
			cancel_description() {
				this.showMask = true
				this.showMask = true;
				this.firstLoadPopup = false;

				let v0 = ''
				request({
					url: '/api/train/getv0AndOntherInfo',
					method: 'GET',
					data: {
						flag: 2
					}
				}).then(res => {
					// 打印返回的数据
					console.log('获取到111的数据：', res)
					let data_list = res.data
					this.v0 = -1
					if (res.data == null) {
						console.log('v0为空')
					} else {
						console.log("当前动作名称", VueEvent.sharedData.map_action[this.action])
						for (let i = 0; i < data_list.length; i++) {
							if (data_list[i].action == VueEvent.sharedData.map_action[this.action]) {
								this.v0 = data_list[i].v0
								if (data_list[i].c1rm != null) {
									this.clrm = data_list[i].c1rm
								} else {
									this.clrm = 0
								}
								if (data_list[i].s1rm != null) {
									this.slrm = data_list[i].s1rm
								} else {
									this.slrm = 0
								}
							}
						}
						console.log("查到的v0为", this.v0)
					}
				}).catch(err => {
					console.error('请求失败：', err)
				})
				let ismember = uni.getStorageSync('userInfo').isMember
				console.log("ismeber", ismember)
				if (this.isauto == true) {
					// 开启自动识别
					this.modalType = 'main'
					if (this.v0 == -1) {
						// 没有v0
						this.showTestModal = true;

					} else {
						// 有v0  带入计算
						this.showTestModal = true;
					}
				} else {
					// 没有开启自动识别
					this.modalType = 'main'
					if (this.v0 == -1) {
						// 没有v0
						console.log("没有开启自动识别且v0为空")
						// this.v0 = null;
						this.showTestModal = true;
					} else {
						// 有v0  带入计算
						console.log("没有开启自动识别，有v0")
						this.showTestModal = true;
					}
				}

				this.loadInputTarget = '1RM';
				this.load1RM = this.rm || 0;
				this.loadWeight = this.burden || 0;
			}
		},
		onLoad(options) {
			this.trainWay = options.trainWay || ''; // 获取训练方式
			this.isFree = options.isFree === 'true'; // 获取是否为自由训练
			this.filePath = `${uni.env.USER_DATA_PATH}/result.docx`;
			this.createFile();
			this.ti = new Date();
			this.gaowei_status = false
			// 根据训练方式设置指标显示
			if (this.isFree) {
				this.indices[2].show = false;
				this.indices[3].show = false;
			}

		},

		components: {
			VersionHeader,
			VersionCanvas,
			Countdown,
		}

	}
</script>
<style lang="less" scoped>
	.layout {
		height: 100%;
		width: 100%;
		background: rgba(124, 124, 126, 0.10);
		// background: blac;
		font-family: "Alibaba PuHuiTi 2.0";
		font-weight: 500;
		padding: 0 40rpx;
		position: relative; // 确保遮罩层定位正确

		.mask {
			position: fixed;
			top: 0;
			left: 0;
			right: 0;
			bottom: 0;
			background: rgba(0, 0, 0, 0.5);
			z-index: 2000;
		}

		.popup-menu {
			position: fixed;
			right: 100rpx;
			bottom: 180rpx;
			z-index: 3000;
			background: #fff;
			border-radius: 20rpx;
			box-shadow: 0 4rpx 32rpx rgba(0, 0, 0, 0.12);
			padding: 20rpx 0;
			min-width: 180rpx;

			.menu-item {
				padding: 24rpx 48rpx;
				font-size: 28rpx;
				color: #222;
				text-align: center;
				white-space: nowrap;
				border-bottom: 1px solid #f0f0f0;

				&:last-child {
					border-bottom: none;
				}

				&.end {
					color: #e74c3c;
				}
			}
		}

		.loss_title {
			margin-top: 32rpx;
			margin-left: 20rpx;
			font-size: 25rpx;
			line-height: 27rpx;
			color: rgba(124, 124, 126, 1);
		}

		.progress {
			margin: auto;
			width: 630rpx;

			.slider-bar {
				position: relative;
				width: 630rpx;
				height: 12px;
				display: flex;
				align-items: center;
				margin: 10px 0;
				padding: 0rpx;

				.circle {
					position: absolute;
					top: -2px;
					width: 14px;
					height: 14px;
					background-color: white;
					border-radius: 50%;
					border: 2px solid purple;
					transition: left 0.3s;
				}
			}

			.labels {
				display: flex;

				justify-content: space-between;
				margin-top: 5px;
				font-size: 20rpx;
				color: gray;
			}
		}








	}

	.grid-container {
		display: grid;
		grid-template-columns: repeat(2, 1fr);
		/* grid-template-rows: repeat(2, 140rpx);  // 删除这一行 */
		grid-row-gap: 45rpx;
		grid-column-gap: 68rpx;
		width: 630rpx;
		margin: 0 auto;
		margin-top: 60rpx;

		.grid-item {
			background: rgba(255, 255, 255, 1);

			padding-top: 15rpx;
			padding-left: 20rpx;
			text-align: center;
			border-radius: 20rpx;
			align-items: center;

			// border: 1px solid black;
			.index {
				display: flex;

				.value {
					// width: 200rpx;
					margin-right: 10rpx;
					font-size: 48rpx;
					font-weight: 500;
					letter-spacing: 0px;
					line-height: 66rpx;
					color: rgba(0, 0, 0, 1);
					text-align: left;
					padding-left: 10rpx;
				}

				.unit {
					/** 文本2 */
					margin-top: 20rpx;
					font-size: 30rpx;
					color: rgba(124, 124, 126, 1);

				}
			}

			.name {
				text-align: left;
				margin-top: -5rpx;
				padding-left: 10rpx;
				font-size: 25rpx;
				color: rgba(124, 124, 126, 1);
			}
		}
	}

	.bar {
		width: 622rpx;
		height: 400rpx;
		padding: 20rpx 30rpx;
		opacity: 1;
		border-radius: 20rpx;
		margin: 50rpx auto;
		// border: 1px solid black;
		background: rgba(255, 255, 255, 1);

		.title {
			display: flex;
			justify-content: space-between;
			font-size: 25rpx;
			// color: black;
		}

		.small_title {
			font-size: 15rpx;
			color: rgba(124, 124, 126, 1);
			margin-bottom: 10rpx;
		}

		.echart_box {
			// border: 1px solid black;
			margin-left: -20rpx;
			height: 320rpx;
			z-index: 1;
			position: relative;
			color: rgba(124, 124, 126, 1);
		}

		::v-deep canvas {
			z-index: 1 !important;
		}
	}

	.tips {
		width: 622rpx;
		height: 72rpx;
		border-radius: 15rpx;
		background: rgba(110, 88, 170, 0.04);
		margin: 10rpx auto;
		display: flex;
		align-items: center;
		padding-left: 10rpx;

		.img {

			width: 40rpx;
			height: 40rpx;
		}

		.content {
			padding-left: 10rpx;
			font-size: 25rpx;
			font-weight: 500;
			color: rgba(110, 88, 170, 1);
		}
	}

	.bottom {
		bottom: 80rpx;
		left: 50%;

		width: 622rpx;
		height: 100rpx;
		border-radius: 54rpx;
		border: 1px solid rgba(124, 124, 126, 0.2);
		// border: 1px solid  black;
		margin: 0 auto;
		margin-left: -311rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		color: rgba(124, 124, 126, 1);

		.bottom-lr {
			width: 70%;
			margin: auto;
			display: flex;
			align-items: center;
			justify-content: space-between;

		}

		img {
			// margin-bottom: 5rpx;
			width: 52rpx;
			height: 50rpx;
		}

		.value_unit {
			display: flex;
			color: rgba(124, 124, 126, 1);

			.value {
				font-size: 32rpx;
			}

			.unit {
				margin-top: 8rpx;
				font-size: 22rpx;
			}
		}

		.name {

			font-size: 22rpx;

			margin-left: 8rpx;
		}

		.small_title {
			margin-top: -10rpx;
			font-size: 25rpx;
			line-height: 21rpx;
			color: rgba(124, 124, 126, 1);
		}

		.button {
			position: absolute;
			left: 50%;
			margin-left: -38rpx;
			top: 50%;
			margin-top: -38rpx;
			width: 76rpx;
			height: 76rpx;
			background: rgba(255, 255, 255, 1);
			border-radius: 50%;
			display: flex;
			align-items: center;
			justify-content: center;

			img {
				width: 40rpx;
				height: 40rpx;
			}
		}
	}

	.more-menu-anchor {
		position: relative;
		display: inline-block;
	}

	.load-popup {
		position: fixed;
		left: 50%;
		bottom: 180rpx;
		transform: translateX(-50%);
		background: rgba(240, 240, 240, 1);
		border-radius: 24rpx;
		box-shadow: 0 4rpx 32rpx rgba(0, 0, 0, 0.12);
		display: flex;
		z-index: 3000;
		min-width: 600rpx;
		min-height: 380rpx;

		.load-popup-left {
			// border: 1px solid black;
			display: flex;
			flex-direction: column;
			justify-content: space-between;
			padding: 32rpx 0rpx 32rpx 32rpx;

			.left_module {
				// border: 1px solid black;
				margin-bottom: 12rpx;
			}

			.load-popup-item {
				font-size: 32rpx;
				font-weight: 600;

				border-radius: 12rpx;
				height: 100rpx;
				width: 100rpx;
				margin: 0 8rpx;
				// background: #f7f7f7;
				// background: rgba(255, 255, 255, 1);
				background: rgba(124, 124, 126, 0.2);
				padding: 18rpx 18rpx;
				// border: 1px solid black;
				position: relative;

				// border: 1px solid black;
				.desc {
					display: block;
					font-size: 20rpx;
					color: #888;
					font-weight: 400;
					margin-top: 4rpx;
					white-space: nowrap;
					display: flex;
					justify-content: center;
				}

				&.editable {
					cursor: pointer;
					border: 2rpx solid transparent;
				}

				&.active {
					// border: 2rpx solid #6e58aa;
					// background: #ede7f6;
					background: rgba(255, 255, 255, 1);
				}
			}
		}




		.load-popup-right {
			// border: 1px solid black;
			display: flex;
			flex-direction: column;
			justify-content: space-between;
			padding: 32rpx 32rpx 32rpx 0rpx;

			.load-popup-item {
				// border: 1px solid black;
				font-size: 32rpx;
				font-weight: 600;
				margin-bottom: 18rpx;
				border-radius: 12rpx;
				height: 100rpx;
				width: 100rpx;
				margin: 0 8rpx;
				// background: #f7f7f7;
				// background: rgba(255, 255, 255, 1);
				background: rgba(124, 124, 126, 0.2);
				padding: 10rpx 0rpx;
				position: relative;

				.desc {

					display: block;
					font-size: 20rpx;
					color: #888;
					font-weight: 400;
					margin-top: 4rpx;
					white-space: nowrap;
					display: flex;
					justify-content: center;
				}

				&.editable {
					cursor: pointer;
					border: 2rpx solid transparent;
				}

				&.active {
					// border: 2rpx solid #6e58aa;
					// background: #ede7f6;
					background: rgba(255, 255, 255, 1);
				}
			}
		}



		.load-popup-keyboard {
			// border: 1px solid black;
			display: flex;
			flex-direction: column;
			justify-content: stretch;
			flex: 1;
			padding: 24rpx 10rpx;

			.row {
				display: flex;
				flex: 1;
				justify-content: space-between;
				margin-bottom: 12rpx;

				&:last-child {
					margin-bottom: 0;
				}

				.key {
					flex: 1;
					margin: 0 8rpx;
					background: rgba(255, 255, 255, 1);
					border-radius: 12rpx;
					// border: 1px solid black;

					display: flex;
					align-items: center;
					justify-content: center;
					font-size: 50rpx;
					font-weight: 500;
					cursor: pointer;
					user-select: none;
					height: 100rpx;
					width: 100rpx;
					min-height: 0;

					&:active {
						background: #e0e0e0;
					}
				}
			}
		}
	}

	.group-menu-anchor {
		position: relative;
		display: inline-block;
		font-size: 25rpx;
	}

	.group-menu {
		position: absolute;
		right: 0;
		top: auto;
		bottom: 100%;
		margin-top: 0;
		margin-bottom: 10rpx;
		z-index: 3000;
		background: #fff;
		border-radius: 20rpx;
		box-shadow: 0 4rpx 32rpx rgba(0, 0, 0, 0.12);
		padding: 10rpx 0;
		min-width: 160rpx;

		.group-menu-item {
			white-space: nowrap;
			padding: 20rpx 40rpx;
			font-size: 28rpx;
			color: #222;
			text-align: center;
			border-bottom: 1px solid #f0f0f0;

			&:last-child {
				border-bottom: none;
			}

			&.danger {
				color: #e74c3c;
			}
		}
	}

	.common-modal {
		position: fixed;
		left: 50%;
		bottom: 80rpx;
		transform: translateX(-50%);
		background: rgba(240, 240, 240, 1);
		border-radius: 18rpx;
		width: 90vw;
		z-index: 10000;
		padding: 40rpx 30rpx 30rpx 30rpx;
		box-sizing: border-box;
	}

	.common-modal-title {
		font-size: 36rpx;
		font-weight: bold;
		text-align: center;
		margin-bottom: 60rpx;
	}

	.common-modal-content {
		font-size: 28rpx;
		color: rgba(0, 0, 0, 1);
		text-align: center;
		margin: 40rpx 60rpx;
		margin-bottom: 100rpx;

	}

	.common-modal-actions {
		display: flex;
		flex-direction: column;
	}

	.btn-cancel,
	.btn-confirm {
		display: inline-block;
		width: 184rpx;
		height: 56rpx;
		line-height: 56rpx;
		font-size: 30rpx;
		/* margin: 0 10rpx; */
		margin-bottom: 56rpx;
		border-radius: 20rpx;
		padding: 0;
		border: none;
		text-align: center;
		box-sizing: border-box;
	}

	.btn-cancel {
		background: rgba(255, 255, 255, 0.5);
		color: #333;
	}

	.btn-confirm {
		position: relative;
		background: rgba(110, 88, 170, 1);
		color: #fff;
	}

	.pro-badge {
		position: absolute;
		top: -18rpx;
		right: 3rpx;
		font-size: 18rpx;
		color: #fff;
		background: rgba(110, 88, 170, 0.9);
		padding: 2rpx 10rpx;
		border-radius: 12rpx;
		font-weight: bold;
		font-size: 10rpx;
		letter-spacing: 1rpx;
		z-index: 1;
		pointer-events: none;
	}

	.common-modal-tips {
		font-size: 16rpx;
		color: #999;
		text-align: center;
		margin-top: 10rpx;
		margin-bottom: 30rpx;
	}

	.modal-list-item {
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 0 24rpx;
		height: 80rpx;
		background: #fff;
		border-bottom: 1px solid #f0f0f0;
		font-size: 32rpx;
		font-weight: bold;
		position: relative;
	}

	.modal-list-item:last-child {
		border-bottom: none;
	}

	.modal-list-label {
		display: flex;
		align-items: center;
	}

	.pro-badge-list {
		margin-left: 12rpx;
		font-size: 20rpx;
		color: #fff;
		background: #7c6ed2;
		padding: 2rpx 12rpx;
		border-radius: 8rpx;
		font-weight: bold;
		letter-spacing: 1rpx;
	}

	.modal-list-arrow {
		font-size: 36rpx;
		color: #bbb;
		font-weight: bold;
		width: 30rpx;
		height: 30rpx;
	}

	.actions-row {
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		margin-bottom: 20rpx;
		gap: 8rpx;
	}

	.actions-col {
		display: flex;
		flex-direction: column;
	}
</style>